import { reactive } from "vue";
import { toast } from "@/components/toast/toast";
const YShare = reactive({
    show: false,
    title: "",
    imgTitle: "",
    blob: document.createElement("canvas"),
    colose: function () {
        let dom = document.getElementById("shuiying");
        if (dom) {
            dom.style.visibility = "hidden";
        }
        this.show = false;
    },
    open: function (canvas: HTMLCanvasElement, title: string = "Title", msg: string = "Image Title") {
        // console.log("yzt", canvas);
        this.title = title;
        this.imgTitle = msg;
        this.blob = canvas;
        this.show = true;
    },
    copyLink(code?: string) {
        let url = location.origin; 
        console.log('打印邀请码',code)
        if(code){
            url = url + "/recommend/" + code;
        }
        const theClipboard = navigator.clipboard;
        // console.log('打印复制',theClipboard)
        if (theClipboard !== undefined) {
            theClipboard.writeText(url).then(on => {
                toast("copy sucess!");
            });
        } else {
            toast("not copy permissions!");
        }
        // new Permissions().query({name:'notifications'})
        // window.navigator.clipboard.writeText(url).then(on => {
        //     console.log('yzt粘贴板',on);
        //     toast("Copy Sucess!");
        // });
    }
});
export { YShare };
